$(function(){
    //enable nivoSlider
    if(($("#slider").css('display')+'').toLowerCase()=='block'){
        $('#slider').nivoSlider();
    }
    //enable trigger btn login
    $("#btnTriggerLogin").bind('click', function(){
        $('#divLogin').toggle('slow');
        $('#btnTriggerLogin').toggle('slow');
    });
    //set link for history back
    $(".backLink").click(function(event) {
        event.preventDefault();
        history.back(1);
    });
//set method for link inside this web    
});
var linkTo = function(parametros){
    $('<form action="?" method="GET"><input type="hidden" name="m" value="'+
        parametros+'" /></form>').appendTo('body').submit();
}

$.fn.serializeObject = function()
{
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};

$(function(){
    $(".closeModal").click(function(){
        $("#modalJv").animate({
            opacity: "toggle"
        });
    });
});
var modalJv = function(msg, btns, enClose){
    if( ($("#modalJv").html()+'')=='undefined' ) {
        var htmlBotones = ( 
            ((enClose+'').toLowerCase()!='undefined') && enClose.length >0 
        )?'<hr/><div id="modalJvBtns">'+btns+'</div>':'';
        
        var htmlModal = '<div class="modalJv" id="modalJv">'+
        '<div class="modalJvN1">'+
        '<div class="modalJvN2 shadowBox" id="boxMsgResp">'+
        '<div class="modalJvN3">'+
        '<i class="icon-remove-sign icon-3x modalJvClose closeModal"></i>'+
        '<span id="modalJvResp">'+msg+'</span>'+htmlBotones+ 
        '</div></div></div></div>';
        $('body').append(htmlModal);
        $("#modalJv").animate({opacity: "show"});
    }else{
        $('#modalJvResp').html(msg);
        $('#modalJvN4').html(btns);
        $("#modalJv").animate({opacity: "show"});
    }
    enableCloseModal(enClose);
}
var enableCloseModal = function(enClose){
    if( (enClose+'').toLowerCase()=='undefined'){
        $(".modalJvClose").show();
    }else if( enClose ){
        $(".modalJvClose").show();
    }else if( !enClose ){
        $(".modalJvClose").hide();
    }
    $(".closeModal").click(function(){
        $("#modalJv").animate({
            opacity: "hide"
        });
    });
}